﻿@using Newtouch.Infrastructure;
@{
    ViewBag.Title = "患者管理";
    Layout = "~/Views/Shared/_Form.cshtml";

    //是否和医保交易
    var openYbSett = SysConfigReader.Bool("Outpatient_ChargeFee_OpenYbSett");
    //是否和新农合交易
    var openXnhSett = SysConfigReader.Bool("Inpatient_Sett_OpenXnhSett");
    //医保所属地
    var medicalInsurance = SysConfigReader.String("Outpatient_MedicalInsurance");
    //出生年月的格式 是否精确到具体时间
    var csnyFormat = "yyyy-MM-dd";
    if (SysConfigReader.Bool("PatientBasicInfo_Birthday_withTime", false).Value)
    {
        csnyFormat = "yyyy-MM-dd HH:mm:ss"; ;
    }
}
<style>
    .formTitle span {
        color: red;
    }

    .tab-content #basicInfo table tr td {
        border: 0;
    }

    input[id$="sheng"], input[id$="shi"], input[id$="xian"] {
        width: 70%;
    }

    input[id$="nlshow"] {
        width: 50%;
    }
</style>
@Html.Partial("_YibaoCommonView")
<form id="form1">
    <div class="panel panel-default">
        <div class="panel-heading navb-bg">
            基本信息
        </div>
        <div class="tab-content">
            <div role="tabpanel" class="tab-pane fade in active" id="basicInfo">
                @*<input type="hidden" id="py" name="py" />*@
                <input type="hidden" id="patid" name="patid" />
                <div id="divYktRegister" class="tab-pane fade in active">
                    <input type="hidden" id="py" name="py" />
                    <table class="form" style="width: 98%; border: 0">
                        <tr>
                            <td class="formTitle">
                                <span>*</span>卡号
                            </td>
                            <td class="formValue">
                                <input type="text" id="kh" class="form-control form-an">
                                <!-- 默认空白，非医保卡 -->
                                <input type="hidden" id="cardtype" value="" />
                                <input type="hidden" id="cbdbm" value="" />
                                <input type="hidden" id="sbbh" value="" />
                                <input type="hidden" id="cblb" value="" />
                                <!--地域编号 0本地 1外地 此处用于异地医保标记-->
                                <input type="hidden" id="dybh" value="" />
                                <input type="hidden" id="xzlx" value="" />
                                <input type="hidden" id="grbh" value="" />
                            </td>
                            <td class="formTitle"><span>*</span>病历号</td>
                            <td class="formValue">
                                <input type="text" id="blh" class="form-control form-an">
                            </td>
                            <td class="formTitle"><span>*</span>患者姓名</td>
                            <td class="formValue">
                                <input type="text" id="xm" name="xm" class="form-control form-an">
                            </td>
                            <td class="formTitle" style="display:none"><span>*</span>患者性质</td>
                            <td class="formValue" style="display:none">
                                <input type="text" id="brxzmc" name="brxzmc" class="form-control form-an">
                            </td>
                            <td class="formTitle"><span>*</span>性别</td>
                            <td class="formValue">
                                <div class="btn-group" data-toggle="buttons">
                                    <label class="btn btn-default">
                                        <input type="radio" id="xb" value="1" name="xb" class="form-control form-an">
                                        男
                                    </label>
                                    <label class="btn btn-default">
                                        <input type="radio" id="xb" value="2" name="xb" class="form-control form-an">
                                        女
                                    </label>
                                </div>
                            </td>
                        </tr>

                    </table>
                </div>
                <div id="divYktModify" class="tab-pane fade in active" style="display:none">
                    <table class="form" style="width: 98%; border: 0">
                        <tr>
                            <td class="formTitle"><span>*</span>病历号</td>
                            <td class="formValue">
                                <input type="text" id="blh" class="form-control form-an">
                            </td>
                            <td class="formTitle"><span>*</span>患者姓名</td>
                            <td class="formValue">
                                <input type="text" id="xm" name="xm" class="form-control form-an">
                            </td>
                            <td class="formTitle" style="display:none"><span>*</span>患者性质</td>
                            <td class="formValue"  style="display:none">
                                    <input type="text" id="brxzmc" name="brxzmc" class="form-control form-an">
                            </td>
                            <td class="formTitle"><span>*</span>拼音</td>
                            <td class="formValue">
                                <input type="text" id="py" name="py" class="form-control form-an">
                            </td>
                            <td class="formTitle"><span>*</span>性别</td>
                            <td class="formValue">
                                <div class="btn-group" data-toggle="buttons">
                                    <label class="btn btn-default">
                                        <input type="radio" id="xb" value="1" name="xb" class="form-control form-an">
                                        男
                                    </label>
                                    <label class="btn btn-default">
                                        <input type="radio" id="xb" value="2" name="xb" class="form-control form-an">
                                        女
                                    </label>
                                </div>
                            </td>

                        </tr>
                    </table>

                </div>
                @*<div class="panel-heading navb-bg">
                        基础信息
                    </div>*@
                <table class="form" style="width: 98%; border: 0">
                    @*<tr>*@
                    <tr>
                        <td class="formTitle"><span class="zjclass">*</span>证件类型</td>
                        <td class="formValue formDdlSelectorTd">
                            @Html.DropDownList("zjlx", EnumZJLX.sfz.ToDescSelectList(), new { @class = "form-control form-an" })
                        </td>
                        <td class="formTitle"><span class="zjclass">*</span>证件号</td>
                        <td class="formValue">
                            <input type="text" id="zjh" name="zjh" onblur="valiPatZjh()" class="form-control form-an">
                        </td>
                        <td class="formTitle"><span>*</span>出生年月</td>
                        <td class="formValue">
                            <input id="csny" type="text" data-dateFmt="@(csnyFormat)" class="form-control input-wdatepicker form-an" onfocus="WdatePicker({
    onpicked: function () { setAge($(this).val()); return true; }, dateFmt: '@(csnyFormat)'
})" />
                        </td>
                        <td class="formTitle">年龄</td>
                        <td class="formValue">
                            <input type="text" id="nlshow" class="form-control form-an" style="float: left" />
                            <select class="form-control" id="nlshowdw" style="width:50px;">
                                <option value=""></option>
                                <option value="1" selected="selected">岁</option>
                                <option value="2">月</option>
                                <option value="3">天</option>
                                <option value="4">小时</option>
                            </select>
                        </td>


                    </tr>
                    <tr>

                        <td class="formTitle">国籍</td>
                        <td class="formValue">
                            <select id="gj2" class="form-control form-an">
                                <option value="">==请选择==</option>
                            </select>
                        </td>
                        <td class="formTitle">民族</td>
                        <td class="formValue">
                            <select id="mz2" class="form-control form-an">
                                <option value="">==请选择==</option>
                            </select>
                        </td>

                        <td class="formTitle"><span></span>籍贯</td>
                        <td class="formValue">
                            <input type="text" id="jg" name="jg" class="form-control form-an">
                        </td>
                        <td class="formTitle">职业</td>
                        <td class="formValue">
                            <select id="zy" class="form-control form-an">
                                <option value="">==请选择==</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td class="formTitle">最佳联系方式</td>
                        <td class="formValue formDdlSelectorTd">
                            <select id="zjlxfs" class="form-control">
                                <option value="">==请选择==</option>
                            </select>
                        </td>
                        <td class="formTitle">微信</td>
                        <td class="formValue">
                            <input type="text" id="wechat" class="form-control form-an">
                        </td>
                        <td class="formTitle">邮箱</td>
                        <td class="formValue">
                            <input type="text" id="email" name="email" class="form-control form-an">
                        </td>
                        <td class="formTitle">手机</td>
                        <td class="formValue">
                            <input type="text" id="phone" name="phone" class="form-control form-an">
                        </td>
                    </tr>
                    <tr>
                        <td class="formTitle">电话</td>
                        <td class="formValue">
                            <input type="text" id="dh" name="dh" class="form-control form-an">
                        </td>
                        <td class="formTitle">患者来源</td>
                        <td class="formValue formDdlSelectorTd">
                            <select class="form-control form-an-end" id="brly" name="brly">
                                <option value="">==请选择==</option>
                            </select>
                        </td>

                        <td class="formTitle">婚否</td>
                        <td class="formValue formDdlSelectorTd">
                            @Html.DropDownList("hf", EnumHF.wh.ToDescSelectList(), "==请选择==", new { @class = "form-control form-an" })
                        </td>

                        <td class="formTitle">学历</td>
                        <td class="formValue">
                            <select id="xl" class="form-control form-an">
                                <option value="">==请选择==</option>
                            </select>
                        </td>
                    </tr>

                    <tr id="citylist_XDZ">
                        <td class="formTitle">现地址：</td>
                        <td class="formValue">
                            <select name="province" class="form-control form-an">
                                <option>请选择</option>
                            </select>
                        </td>
                        <td class="formValue">省(区，市)</td>
                        <td class="formValue">
                            <select name="city" class="form-control form-an">
                                <option>请选择</option>
                            </select>
                        </td>
                        <td class="formValue">市</td>
                        <td class="formValue">
                            <select name="area" class="form-control form-an">
                                <option>请选择</option>
                            </select>
                        </td>
                        <td class="formTitle"><span style="float:left;color:#475059">县</span>&nbsp;&nbsp;<span style="float:right;color:#475059">地址：</span></td>
                        <td class="formValue"><input type="text" id="xian_dz" class="form-control form-an" /></td>

                    </tr>

                    <tr id="citylist_CSD">
                        <td class="formTitle">出生地：</td>
                        <td class="formValue">
                            <select name="province" class="form-control form-an">
                                <option>请选择</option>
                            </select>

                        </td>
                        <td class="formValue">省(区，市)</td>
                        <td class="formValue">
                            <select name="city" class="form-control form-an">
                                <option>请选择</option>
                            </select>
                        </td>
                        <td class="formValue">市</td>
                        <td class="formValue">
                            <select name="area" class="form-control form-an">
                                <option>请选择</option>
                            </select>
                        </td>
                        <td class="formTitle"><span style="float:left;color:#475059">县</span>&nbsp;&nbsp;<span style="float:right;color:#475059">地址：</span></td>
                        <td class="formValue">
                            <input type="text" id="cs_dz" class="form-control form-an form-an-end" />
                        </td>
                    </tr>

                    <tr id="citylist_HKDZ">
                        <td class="formTitle">户口地址：</td>
                        <td class="formValue">
                            <select name="province" class="form-control form-an">
                                <option>请选择</option>
                            </select>
                        </td>
                        <td class="formValue">省(区，市)</td>
                        <td class="formValue">
                            <select name="city" class="form-control form-an">
                                <option>请选择</option>
                            </select>
                        </td>
                        <td class="formValue">市</td>
                        <td class="formValue">
                            <select name="area" class="form-control form-an">
                                <option>请选择</option>
                            </select>
                        </td>
                        <td class="formTitle"><span style="float:left;color:#475059">县(区)</span>&nbsp;&nbsp;<span style="float:right;color:#475059">地址：</span></td>
                        <td class="formValue"><input type="text" id="hu_dz" class="form-control form-an" /></td>
                    </tr>
                    <tr>
                        <td class="formTitle">紧急联系人关系</td>
                        <td class="formValue formDdlSelectorTd">
                            <select id="jjllrgx" name="jjllrgx" class="form-control form-an">
                                <option value="">==请选择==</option>
                            </select>
                        </td>
                        <td class="formTitle">紧急联络人</td>
                        <td class="formValue">
                            <input type="text" id="jjllr" class="form-control form-an">
                        </td>
                        <td class="formTitle">紧急联络电话</td>
                        <td class="formValue">
                            <input type="text" id="jjlldh" name="jjlldh" class="form-control form-an">
                        </td>
                    </tr>
                    <tr id="citylist_JJLXRDZ">
                        <td class="formTitle">联系人地址：</td>
                        <td class="formValue">
                            <select name="province" class="form-control form-an">
                                <option>请选择</option>
                            </select>
                        </td>
                        <td class="formValue">省(区，市)</td>
                        <td class="formValue">
                            <select name="city" class="form-control form-an">
                                <option>请选择</option>
                            </select>
                        </td>
                        <td class="formValue">市</td>
                        <td class="formValue">
                            <select name="area" class="form-control form-an">
                                <option>请选择</option>
                            </select>
                        </td>
                        <td class="formTitle">县(区) &nbsp;&nbsp; 地址：</td>
                        <td class="formValue"><input type="text" id="jjlxr_dz" class="form-control form-an" /></td>

                    </tr>
                </table>
            </div>
            @*<div id="extentInfo" role="tabpanel" class="tab-pane fade in">*@
            <table class="form" style="width: 98%; border: 0">
                <tr>
                    <td class="formTitle">单位</td>
                    <td class="formValue">
                        <input type="text" id="dwmc" class="form-control form-an">
                    </td>

                    <td class="formTitle">单位地址</td>
                    <td class="formValue">
                        <input type="text" id="dwdz" class="form-control form-an">
                    </td>
                    <td class="formTitle">单位电话</td>
                    <td class="formValue">
                        <input type="text" id="dwdh" class="form-control form-an form-an-end">
                    </td>

                    @*<td class="formTitle">备注</td>
                        <td class="formValue">
                            <input type="text" id="bz" class="form-control form-an form-an-end">
                        </td>*@
                </tr>
                <tr>
                    <td class="formTitle">出生地邮编</td>
                    <td class="formValue">
                        <input type="text" id="cs_yb" class="form-control form-an">
                    </td>

                    <td class="formTitle">现住址邮编</td>
                    <td class="formValue">
                        <input type="text" id="xian_yb" class="form-control form-an">
                    </td>
                    <td class="formTitle">户口地邮编</td>
                    <td class="formValue">
                        <input type="text" id="hu_yb" class="form-control form-an form-an-end">
                    </td>
                    <td class="formTitle">单位邮编</td>
                    <td class="formValue">
                        <input type="text" id="dwyb" class="form-control form-an form-an-end">
                    </td>

                </tr>
                <tr>
                    <td class="formTitle">过敏史</td>
                    <td class="formValue">
                        <input type="text" id="gms" class="form-control form-an form-an-end">
                    </td>
                    <td class="formTitle">疾病史</td>
                    <td class="formValue">
                        <input type="text" id="jbs" class="form-control form-an form-an-end">
                    </td>
                    <td class="formTitle">备注</td>
                    <td class="formValue">
                        <input type="text" id="bz" class="form-control form-an form-an-end">
                    </td>
                </tr>
            </table>
            @*</div>*@
        </div>
    </div>
</form>
<form id="formPatSer" style="margin:2px;margin-top:10px;">
    <div class="gridPanel" id="divPatCard">
        <table id="patGridList" rel="formPatSer"></table>
    </div>
</form>
<script type="text/javascript" src="@SiteUrl.GetStaticResourceScriptUrl("~/Content/js/PatientManage/HospiterRes/PatientBasic.js",false)"></script>
<script src="~/Content/js/jquery.citys.js"></script>
<script type="text/javascript">
    var openYbSett = '@openYbSett' === 'True'; //开关配置：医保患者是否使用医保交易流程
    var medicalInsurance = '@medicalInsurance';//医保所属地配置:区分医院所属医保区域

    var zjpz = "@ViewBag.zjpz";
    var khpz = "@ViewBag.khpz";
    var blhpz = "@ViewBag.blhpz";
    var xnkCardType = "@((int)EnumCardType.XNK)";
    var ybkCardType = "@((int)EnumCardType.YBJYK)";
</script>


@if (openYbSett == true || openXnhSett == true)
{
    <script type="text/javascript">
        var patientform = JSON.parse(localStorage.getItem("patientform"));
        var khsc = true;
        var blhsc = true;
        $(function () {
            if (!!patientform) {
                fillForm();
                localStorage.removeItem("patientform");
            }
            else {
                brxzinit();
                
            }

            if (!!keyValue) {
                $("#kh").attr("disabled", "disabled").css("background-color", "#f1f4f6");
                $("#blh").attr("disabled", "disabled").css("background-color", "#f1f4f6");
                $.najax({
                    url: "/PatientManage/HospiterRes/GetFormJson?T=" + new Date(),
                    data: { "keyValue": keyValue},
                    dataType: 'json',
                    async: false,
                    success: function (rep) {
                        if (rep.state !== 'error') {
                            $("#form1").formSerialize(rep);
                            cityref = rep;
                            if (rep["brxz"]) {
                                $("#brxzmc").attr("data-label", rep["brxz"]);
                            }
                            if (rep["zjlx"]) {
                                var type = rep["zjlx"].trim();
                                switch (type) {
                                case "1":
                                    type = "身份证";
                                    break;
                                case "2":
                                    type = "护照";
                                    break;
                                case "3":
                                    type = "军官证";
                                    break;
                                default:
                                    break;
                                }
                            }
                            
                            if (rep["gjCode"]) {
                                $("#gj2").val(rep["gjCode"]).trigger('change');
                            }
                            if (rep["mzCode"]) {
                                $("#mz2").val(rep["mzCode"]).trigger('change');
                            }
                            if (rep["brxzmc"] && rep["brxz"]) {
                                $("#brxzmc").attr("data-label", rep["brxz"]);
                                $("#brxzmc").val(rep["brxzmc"]);
                            }

                            if (rep["jjllrgx"]) {
                                $("#jjllrgx").find("option[value='" + rep["jjllrgx"] + "']").attr("selected", true).trigger('change');
                            }
                            setAge(rep.csny);
                        }
                        else {
                            $.modalClose();
                        }
                    },
                    errorCallback: function (err) {
                        $.loading(false);
                    }
                });
            }
            else {
                //是新登记
                if (khpz === 'ON') {
                    $("#kh").attr("disabled", "disabled").css("background-color", "#f1f4f6");
                }
                if (blhpz == 'ON') {
                    //病历号自动生成
                    $("#blh").attr("disabled", "disabled").css("background-color", "#f1f4f6");
                }
                if (khpz === 'ON' || blhpz === 'ON') {
                    //同步请求后台 获取最新虚拟卡号/自动生成病历号
                    $.ajax({
                        url: "/PatientManage/HospiterRes/GetNewCardNoAndBLH",
                        data: { khsc: khsc, blhsc: blhsc },
                        dataType: "json",
                        async: false,
                        cache: false,
                        success: function (data) {
                            $('#kh').val(data.kh);
                            $('#blh').val(data.blh);
                        }
                    });
                    if (!!patientform) {
                        if (!!patientform.blh) {
                            $('#blh').val(patientform.blh);
                        }

                        if (!!patientform.kh) {
                            $('#kh').val(patientform.kh);
                        }
                    } else {
                        $('#nlshow').val("");
                        $('#mz').val("");
                        //$('#gj2').val("");
                        $("#hf").val("");
                    }

                }
              
            }
        });

        //填充
        function fillForm() {
            if (patientform) {//社保
                var yibaoCardInfo = patientform;
                if (yibaoCardInfo) {
                    switch (yibaoCardInfo.ybVer) {
                        case "shanghaiV5":
                            shanghaiV5(yibaoCardInfo);
                            break;
                        case "gjyb":
                            gjyb(yibaoCardInfo);
                            break;
                    }
                } else {
                    $.loading(false);
                    $.modalAlert("刷卡获取医保信息失败！失败原因：医保中心无信息返回，请重试！", 'error');
                }
            }
        }

        function shanghaiV5(yibaoCardInfo)
        {
            var ybfyxzCompResult;
            if (yibaoCardInfo.xxfhm === "P001") {
                var ybPatInfo = yibaoCardInfo.sm01;
                if (ybPatInfo) {
                    if (yibaoCardInfo.kh == null || yibaoCardInfo.kh == "") {
                        $.ajax({
                            url: "/PatientManage/HospiterRes/GetNewCardNoAndBLH",
                            data: { khsc: khsc, blhsc: blhsc },
                            dataType: "json",
                            async: false,
                            cache: false,
                            success: function (data) {
                                yibaoCardInfo.kh = data.kh;
                            }
                        });
                    } else {
                        $('#kh').val(yibaoCardInfo.kh);
                    }
                    if (!!!keyValue) {
                        //是新增
                        $('#cardtype').val(yibaoCardInfo.jzlx);
                        $('#kh').val(yibaoCardInfo.kh);    //个人编号 暂作为系统卡号
                    }
                    else {
                        //是修改
                        if ($('#kh').val() !== yibaoCardInfo.kh) {
                            $.modalAlert("错误：非同一张卡", 'error');
                            return false;
                        }
                    }
                    $('#cardtype').val(yibaoCardInfo.jzlx);

                    $('#cblb').val(ybPatInfo.accountattr);
                    //重庆医保，根据返回的行政区划编码区分本地和异地就医人员，本地就医人员的行政区划编码长度小于6位，异地就医人员的行政区划编码为6位
                    //新接口统筹区划统一6位50开头var bkbz = sm01Info.accountattr.substr(11, 1)
                    if (ybPatInfo.accountattr.substr(11, 1)=="Y") {
                        $('#dybh').val("1");
                    } else {
                        $('#dybh').val("0");
                    }
                    khsc = false;
                    //社保编号
                    $('#sbbh').val(yibaoCardInfo.kh);  //个人编号
                    //参保地编码
                    $('#cbdbm').val(ybPatInfo.xzqh);    //分中心编号
                    $('#phone').val(ybPatInfo.lxdh);
                    //身份证 等等赋值
                    $('#xm').val(ybPatInfo.xm);    //姓名
                    //证件类型 医保字典0身份证 1护照
                    var thisZjlx = '1';
                    if (!!thisZjlx)
                        $("#zjlx").val(thisZjlx).trigger('change');
                    if (!!ybPatInfo.sfzh) {
                        $('#zjh').val(ybPatInfo.sfzh);   //证件号
                    }
                    var idCard = ybPatInfo.sfzh;
                    var birthday = idCard.substring(6, 10) + "-" + idCard.substring(10, 12) + "-" + idCard.substring(12, 14);
                    $('#csny').val(birthday);
                    setAge($('#csny').val());
                    $('#xian_dz').val(ybPatInfo.txdz);//使用地址
                    //性别 医保字典1男2女
                    $("input[name=xb]").parent().removeClass('active');
                    $("input[name=xb]").removeAttr('checked'); 
                    if (ybPatInfo.xb % 2 == 0)
                        $("input[name=xb]:eq(0)").trigger('click'); //男
                    else if (ybPatInfo.gend == '2')
                        $("input[name=xb]:eq(1)").trigger('click'); //女

                    $("#brxzmc").val('普通医保').attr("data-label", '1');
                   
                }
                else {
                    $.modalAlert(yibaoCardInfo.fhxx, 'error');
                    return false;
                }
            } else
                $.modalAlert("刷卡失败:" + yibaoCardInfo.fhxx, 'error');
        }

        function gjyb(yibaoCardInfo)
        {
            var thisZjlx;
            var ybfyxzCompResult;
            if (yibaoCardInfo.infcode == "0" || yibaoCardInfo.infcode === 0) {
                var ybPatInfo = yibaoCardInfo.output.baseinfo;
                var ybPatInfo2 = yibaoCardInfo.output.insuinfo[0];//参保信息
                //var ybPatInfo3 = yibaoCardInfo.output.cardecinfo;//卡信息
                if (ybPatInfo) {
                    if (yibaoCardInfo.kh == null || yibaoCardInfo.kh == "") {
                        $.ajax({
                            url: "/PatientManage/HospiterRes/GetNewCardNoAndBLH",
                            data: { khsc: khsc, blhsc: blhsc },
                            dataType: "json",
                            async: false,
                            cache: false,
                            success: function (data) {
                                yibaoCardInfo.kh = data.kh;
                            }
                        });
                    } else {
                        $('#kh').val(yibaoCardInfo.kh);
                    }
                    if (!!!keyValue) {
                        //是新增
                        $('#cardtype').val(yibaoCardInfo.jzlx);
                        $('#kh').val(yibaoCardInfo.kh);    //个人编号 暂作为系统卡号
                    }
                    else {
                        //是修改
                        if ($('#kh').val() !== yibaoCardInfo.kh) {
                            $.modalAlert("错误：非同一张卡", 'error');
                            return false;
                        }
                    }
                    $('#cardtype').val(yibaoCardInfo.jzlx);

                    $('#cblb').val(ybPatInfo2.psn_type);
                    //重庆医保，根据返回的行政区划编码区分本地和异地就医人员，本地就医人员的行政区划编码长度小于6位，异地就医人员的行政区划编码为6位
                    //新接口统筹区划统一6位50开头
                    if (!!ybPatInfo2.insuplc_admdvs && ybPatInfo2.insuplc_admdvs.length == 6 && yibaoCardInfo.kh != null && yibaoCardInfo.kh.substring(0, 1) == "#") {
                        $('#dybh').val("1");
                    } else {
                        $('#dybh').val("0");
                    }
                    $('#xzlx').val(ybPatInfo2.insutype);//险种类型
                    $('#grbh').val(ybPatInfo.psn_no);//人员编号
                    khsc = false;
                    //社保编号
                    $('#sbbh').val(yibaoCardInfo.kh);  //个人编号
                    //参保地编码
                    $('#cbdbm').val(ybPatInfo2.insuplc_admdvs);    //分中心编号
                    //$('#phone').val(ybPatInfo.lxdh);
                    //身份证 等等赋值
                    $('#xm').val(ybPatInfo.psn_name);    //姓名
                    //证件类型 医保字典0身份证 1护照
                    thisZjlx = '1';
                    if (!!thisZjlx)
                        $("#zjlx").val(thisZjlx).trigger('change');
                    if (!!ybPatInfo.certno) {
                        $('#zjh').val(ybPatInfo.certno);   //证件号
                        var birth = ybPatInfo.brdy;
                        $('#csny').val($.getDate({ date: birth })); //出生年月
                        setAge($('#csny').val());  //年龄计算
                    }
                    //$('#xian_dz').val(ybPatInfo.zz);//使用地址
                    //性别 医保字典1男2女
                    $("input[name=xb]").parent().removeClass('active');
                    $("input[name=xb]").removeAttr('checked'); 
                    if (ybPatInfo.gend == '1')
                        $("input[name=xb]:eq(0)").trigger('click'); //男
                    else if (ybPatInfo.gend == '2')
                        $("input[name=xb]:eq(1)").trigger('click'); //女

                    var resultObjArr = new Array();
                    $.each(top.window.clients.sysPatientNatureList, function (idx, val) {
                        if (val.xzlx && val.xzlx == ybPatInfo2.insutype) {
                            resultObjArr.push(val);
                        }
                    });
                    if (!!resultObjArr) {
                        if (resultObjArr.length == 0) {
                            var instype = "";
                            instype = ybPatInfo2.insutype;
                            $.ajax({
                                url: "/PatientManage/HospiterRes/GetBrxzbyxzlx",
                                data: { xzlx: instype },
                                dataType: "json",
                                async: false,
                                cache: false,
                                success: function (data) {
                                    if (!!data) {
                                        $("#brxzmc").val(data.brxzmc).attr("data-label", data.brxz);
                                    }
                                    else {
                                        $("#brxzmc").val('普通医保').attr("data-label", '1');
                                    }
                                }
                            });
                        }
                        else {
                            $("#brxzmc").val(resultObjArr[0].brxzmc).attr("data-label", resultObjArr[0].brxz);
                        }

                    }
                    else {
                        $("#brxzmc").val('普通医保').attr("data-label", '11');
                    }
                }
                else {
                    $.modalAlert(yibaoCardInfo.err_msg, 'error');
                    return false;
                }
            } else
                $.modalAlert("刷卡失败:" + yibaoCardInfo.err_msg, 'error');
        }

        function getcitycode(data) {
            $("tr[id*='citylist_']").each(function (i, e) {
                //debugger
                var sncode = "";
                var sicode = "";
                var qxcode = "";
                if (e.id.indexOf('_XDZ') != -1) {
                    sncode = $(this).find(" select[name='province']").find("option:contains('" + data.xian_sheng + "')").val();
                    $(this).find(" select[name='province']").val(sncode).trigger("change");
                    sicode = $(this).find(" select[name='city']").find("option:contains('" + data.xian_shi + "')").val();
                    $(this).find(" select[name='city']").val(sicode).trigger("change");
                    qxcode = $(this).find(" select[name='area']").find("option:contains('" + data.xian_xian + "')").val();
                    $(this).find(" select[name='area']").val(qxcode).trigger("change");
                }
                else if (e.id.indexOf('_CSD') != -1) {
                    sncode = $(this).find(" select[name='province']").find("option:contains('" + data.cs_sheng + "')").val();
                    $(this).find(" select[name='province']").val(sncode).trigger("change");
                    sicode = $(this).find(" select[name='city']").find("option:contains('" + data.cs_shi + "')").val();
                    $(this).find(" select[name='city']").val(sicode).trigger("change");
                    qxcode = $(this).find(" select[name='area']").find("option:contains('" + data.cs_xian + "')").val();
                    $(this).find(" select[name='area']").val(qxcode).trigger("change");
                }
                else if (e.id.indexOf('_HKDZ') != -1) {
                    sncode = $(this).find(" select[name='province']").find("option:contains('" + data.hu_sheng + "')").val();
                    $(this).find(" select[name='province']").val(sncode).trigger("change");
                    sicode = $(this).find(" select[name='city']").find("option:contains('" + data.hu_shi + "')").val();
                    $(this).find(" select[name='city']").val(sicode).trigger("change");
                    qxcode = $(this).find(" select[name='area']").find("option:contains('" + data.hu_xian + "')").val();
                    $(this).find(" select[name='area']").val(qxcode).trigger("change");
                }
                else if (e.id.indexOf('_JJLXRDZ') != -1) {
                    sncode = $(this).find(" select[name='province']").find("option:contains('" + data.jjlxr_sheng + "')").val();
                    $(this).find(" select[name='province']").val(sncode).trigger("change");
                    sicode = $(this).find(" select[name='city']").find("option:contains('" + data.jjlxr_shi + "')").val();
                    $(this).find(" select[name='city']").val(sicode).trigger("change");
                    qxcode = $(this).find(" select[name='area']").find("option:contains('" + data.jjlxr_xian + "')").val();
                    $(this).find(" select[name='area']").val(qxcode).trigger("change");
                }
            });
        }

        function savecitycode(savedata) {
            $("tr[id*='citylist_']").each(function (i, e) {
                //debugger
                if (e.id.indexOf('_XDZ') != -1) {
                    //$('#citylist_CSD select[name="province"] option:selected').text()
                    savedata.xian_sheng = $(this).find(" select[name='province'] option:selected ").text().replace(' - 请选择 - ', '');
                    savedata.xian_shi = $(this).find(" select[name='city'] option:selected").text().replace(' - 请选择 - ', '');
                    savedata.xian_xian = $(this).find(" select[name='area'] option:selected").text().replace(' - 请选择 - ', '');
                }
                else if (e.id.indexOf('_CSD') != -1) {
                    savedata.cs_sheng = $(this).find(" select[name='province'] option:selected").text().replace(' - 请选择 - ', '');
                    savedata.cs_shi = $(this).find(" select[name='city'] option:selected").text().replace(' - 请选择 - ', '');
                    savedata.cs_xian = $(this).find(" select[name='area'] option:selected").text().replace(' - 请选择 - ', '');
                }
                else if (e.id.indexOf('_HKDZ') != -1) {
                    savedata.hu_sheng = $(this).find(" select[name='province'] option:selected").text().replace(' - 请选择 - ', '');
                    savedata.hu_shi = $(this).find(" select[name='city'] option:selected").text().replace(' - 请选择 - ', '');
                    savedata.hu_xian = $(this).find(" select[name='area'] option:selected").text().replace(' - 请选择 - ', '');
                }
                else if (e.id.indexOf('_JJLXRDZ') != -1) {
                    savedata.jjlxr_sheng = $(this).find(" select[name='province'] option:selected").text().replace(' - 请选择 - ', '');
                    savedata.jjlxr_shi = $(this).find(" select[name='city'] option:selected").text().replace(' - 请选择 - ', '');
                    savedata.jjlxr_xian = $(this).find(" select[name='area'] option:selected").text().replace(' - 请选择 - ', '');
                    savedata.lxrdz = savedata.jjlxr_sheng + savedata.jjlxr_shi + savedata.jjlxr_xian + $("#jjlxr_dz").val();
                }
            });
            return savedata;
        }
        $(window).load(function () {
            if (fromly === "yktmodify") {
                setTimeout(function () {
                    getcitycode(cityref);
                }, 2000);
            }
        });
    </script>
}
